package theOrbalEra.client.handler;

import java.util.EnumSet;

import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import org.lwjgl.input.Keyboard;

import theOrbalEra.client.gui.GuiTheOrbalEra;
import theOrbalEra.common.TheOrbalEra;
import theOrbalEra.common.item.OrbalItemOrbment;
import theOrbalEra.common.util.OrbalUtils;
import theOrbalEra.common.util.GetName;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.TickType;

public class KeyHandler extends cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler {

	public static KeyBinding zKey = new KeyBinding(GetName.localize("key.release"), Keyboard.KEY_Z);
	public static KeyBinding xKey = new KeyBinding(GetName.localize("key.switchNext"), Keyboard.KEY_X);
	public static KeyBinding cKey = new KeyBinding(GetName.localize("key.switchPrior"), Keyboard.KEY_C);
	public boolean doneStuff = false;
	private final OrbalArtsHandlerClient doOrbalArts=new OrbalArtsHandlerClient();
	
	public KeyHandler() {
		super(new KeyBinding[] { zKey,xKey,cKey}, new boolean[] { false ,false,false});
	}

	@Override
	public String getLabel() {
		return null;
	}

	@Override
	public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
		if(FMLClientHandler.instance().getClient().currentScreen == null) {
			if(FMLClientHandler.instance().getClient().ingameGUI instanceof GuiTheOrbalEra){
				GuiTheOrbalEra gui =(GuiTheOrbalEra) FMLClientHandler.instance().getClient().ingameGUI;

				if(kb.keyCode == Keyboard.KEY_X) {
					if (doneStuff == false ) {
						gui.moveNext();
						doneStuff=true;
					}
					
				}
				if(kb.keyCode == Keyboard.KEY_C) {
					if (doneStuff == false ) {
						gui.moveprior();
						doneStuff=true;
					}
					
				}
				}
			}
		}

	@Override
	public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
		doneStuff = false;
	}

	@Override
	public EnumSet<TickType> ticks() {
		return EnumSet.of(TickType.PLAYER);
	}
}